package testPackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class PageFactoryDemoClass {
    WebDriver driver;
    @FindBy(id = "q")
    WebElement searchTextBox;
    @FindBy(xpath = "//*[@id=\"J_TSearchForm\"]/div[1]/button")
    WebElement searchButton;
    //构造方法 初始化所有要定位的元素
    public PageFactoryDemoClass(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver,this);
    }
    //
    public void search(String searchTerm){
        searchTextBox.sendKeys(searchTerm);
        searchButton.click();
    }
}
